from django import forms
from django.contrib.auth.models import User

class EmployeeLoginForm(forms.Form):
    username = forms.CharField(label=u'Username', max_length=30)
    password = forms.CharField(
        label=u'Password',
        widget=forms.PasswordInput()
    )

class UserForm(forms.Form):
    #staff = forms.BooleanField(required=False)
    active = forms.BooleanField(required=False)

class EmployeeAccountForm(forms.Form):
    first_name = forms.CharField(max_length=30, required=True)
    last_name = forms.CharField(max_length=30, required=True)
    email = forms.EmailField(max_length=75, required=True)
    
class EmployeePasswordForm(forms.Form):
    old_password = forms.CharField(label=u'Old password',widget=forms.PasswordInput())
    new_password = forms.CharField(label=u'New password',widget=forms.PasswordInput())
    again_password = forms.CharField(label=u'Again new password',widget=forms.PasswordInput())
    
    def clean_again_password(self):
        if 'new_password' in self.cleaned_data:
            password1 = self.cleaned_data['new_password']
            password2 = self.cleaned_data['again_password']
            if password1 == password2:
                return password2
        raise forms.ValidationError('New password do not match.')
    